import counselorView from '@/views/counselor/CounselorView.vue'
import type { RouteRecordRaw } from 'vue-router'
import { useUserStore } from '@/stores/auth/user'

// 咨询师相关的路由配置
export const counselorRoutes: RouteRecordRaw[] = [
    {
        path: '/counselors',
        name: 'counselors',
        component: counselorView,
        meta: {
            title: '加入我们',
            requiresAuth: true,
        },
        beforeEnter: (to) => {
            const userStore = useUserStore()
            if (to.meta?.requiresAuth && !userStore.isLoggedIn) {
                // 未登录：跳转到登录页，并带上回跳地址
                return { path: '/login', query: { redirect: to.fullPath } }
            }
            return true
        }
    }
]